﻿using System.Collections.Generic;
using System.Linq;
using Foothill.Common;
using Foothill.Filter.Test.TestUtilities;
using Foothill.Model;
using Foothill.Service.AdService;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Foothill.Filter.Test
{
    [TestClass]
    public class AdListFilterLocationListTest
    {
        private IAdListFilter _adListFilter;

        private ForSaleAd _vancouverCar;
        private ForSaleAd _richmondCar;
        private ForSaleAd _burnabyCar1;
        private ForSaleAd _burnabyCar2;

        private IList<ForSaleAd> _carList;

        [TestInitialize]
        public void Setup()
        {
            _adListFilter = new AdListFilter();

            _vancouverCar = new ForSaleAd { CityId = (int)City.Vancouver };
            _richmondCar = new ForSaleAd { CityId = (int)City.Richmond };
            _burnabyCar1 = new ForSaleAd { CityId = (int)City.Burnaby };
            _burnabyCar2 = new ForSaleAd { CityId = (int)City.Burnaby };

            _carList = new List<ForSaleAd> { _vancouverCar, _richmondCar, _burnabyCar1, _burnabyCar2 };
        }

        [TestMethod]
        public void ShouldReturnTwoBurnabyCars()
        {
            ForSaleAdAdvancedSearchParameter param = new ForSaleAdAdvancedSearchParameter(new List<int> { (int)City.Vancouver, (int)City.Richmond, (int)City.Burnaby });
            param.IncludeAllMakes = true;
            param.AllLocationSelected = false;
            param.AddSelectedCityIdList(new List<int> {(int)City.Burnaby});

            IList<ForSaleAd> actual = _adListFilter.FilterSearchResultList(param, _carList);
            IList<ForSaleAd> expected = new List<ForSaleAd> { _burnabyCar1, _burnabyCar2 };

            Assert.IsTrue(actual.SequenceEqual(expected, new SimpleAdIdEqualityComparer()));
        }
    }
}
